<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

<ui:define name="head">
    <title>预收款收据查询</title>
    <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
    <script type="text/javascript" language="javascript">
        document.onkeydown = function TabReplace() {
            if (event.keyCode == 13) {
                if (event.srcElement.tagName != 'BUTTON')
                    event.keyCode = 9;
                else
                    event.srcElement.click();
            }
        }
    </script>
</ui:define>
<ui:define name="content">
<div style="margin:5px;">
<h:form id="form" enctype="multipart/form-data">
<p:growl id="msgs" showDetail="true"/>
<p:focus for="id"/>
<p:panel id="ppCondition" style="width: 100%">
    <h:panelGrid columns="2" style="width: 100%">
        <h:panelGrid id="pgCust" widgetVar="WvCust" columns="4" style="text-align: right;">
            <h:outputLabel value="纳税人识别号:" for="id" style="font-weight: bold;"/>
            <p:inputText id="id" value="#{advanceReceiptsAction.queryCondition.taxerID}"/>

            <h:outputLabel value="纳税人名称:" for="name" style="font-weight: bold;margin-left: 100px;"/>
            <p:inputText id="name" value="#{advanceReceiptsAction.queryCondition.taxerName}"/>

            <h:outputLabel value="所属日期起:" for="startDate" style="font-weight: bold"/>
            <p:inputText id="startDate" value="#{advanceReceiptsAction.queryCondition.dateStart}"
                         onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>

            <h:outputLabel value="所属日期止:" for="endDate" style="font-weight: bold"/>
            <p:inputText id="endDate" value="#{advanceReceiptsAction.queryCondition.dateEnd}"
                         onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>

            <h:outputLabel value="所属税务机关:" for="taxOrgan" style="font-weight: bold"/>
            <p:inputText id="taxOrgan" value="#{advanceReceiptsAction.queryCondition.taxAuthority}"/>

            <h:outputLabel value="主管税务管员:" for="taxManager" style="font-weight: bold"/>
            <p:inputText id="taxManager" value="#{advanceReceiptsAction.queryCondition.taxManager}"/>
        </h:panelGrid>
        <h:panelGrid style="width:10%">
            <p:commandButton id="qryBtn" value="查 询" actionListener="#{advanceReceiptsAction.query()}"
                             style="font-size: 14px;width: 80px;" update="tabSum,msgs">
            </p:commandButton>
            <p:commandButton id="resetBtn" type="reset" value="重 置"
                             style="font-size: 14px;width: 80px;">
            </p:commandButton>
        </h:panelGrid>
    </h:panelGrid>
</p:panel>

<p:ajaxStatus style="width:16px;height:16px;">
    <f:facet name="start">
        <h:graphicImage value="/images/ajaxloading.gif"/>
    </f:facet>
    <f:facet name="complete">
        <h:outputText value=""/>
    </f:facet>
</p:ajaxStatus>
<p:dataTable id="tabSum" style="width:100%;"
             value="#{advanceReceiptsAction.advanceReceiptInfos}"
             var="advanceReceiptInfo"
             rowKey="#{advanceReceiptInfo.pkid}"
             selectionMode="single"
             selection="#{advanceReceiptsAction.advanceReceiptInfoSelected}"
             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
             paginator="true"
             paginatorPosition="bottom"
             rows="15"
             rowsPerPageTemplate="100,50,30,15,5"
             emptyMessage="数据记录为空..."
             widgetVar="tabSumVar">

    <p:ajax event="rowSelect" listener="#{advanceReceiptsAction.updateAdvanceReceiptInfo()}"
            update=":form:tabDetail"/>

    <p:column style="text-align:center" sortBy="#{advanceReceiptInfo.NSRSBH}">
        <f:facet name="header">
            <h:outputText value="纳税人识别号"/>
        </f:facet>
        <h:outputText value="#{advanceReceiptInfo.NSRSBH}"/>
    </p:column>

    <p:column style="text-align:center" filterBy="#{advanceReceiptInfo.NSRMC}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="纳税人名称"/>
        </f:facet>
        <h:outputText value="#{advanceReceiptInfo.NSRMC}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{advanceReceiptInfo.COUNT}">
        <f:facet name="header">
            <h:outputText value="收据份数"/>
        </f:facet>
        <h:outputText value="#{advanceReceiptInfo.COUNT}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{advanceReceiptInfo.price}">
        <f:facet name="header">
            <h:outputText value="总金额"/>
        </f:facet>
        <h:outputText value="#{advanceReceiptInfo.price}">
            <f:convertNumber pattern="##################.##"/>
        </h:outputText>
    </p:column>

    <p:column style="text-align:center" sortBy="#{advanceReceiptInfo.CHCount}">
        <f:facet name="header">
            <h:outputText value="冲红份数"/>
        </f:facet>
        <h:outputText value="#{advanceReceiptInfo.CHCount}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{advanceReceiptInfo.CHPrice}">
        <f:facet name="header">
            <h:outputText value="冲红金额"/>
        </f:facet>
        <h:outputText value="#{advanceReceiptInfo.CHPrice}">
            <f:convertNumber pattern="##################.##"/>
        </h:outputText>
    </p:column>

    <p:column style="text-align:center" filterBy="#{advanceReceiptInfo.taxAuthority}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="税务机关"/>
        </f:facet>
        <h:outputText value="#{advanceReceiptInfo.taxAuthority}"/>
        <f:facet name="footer">
            <h:outputText value="笔数：#{fn:length(advanceReceiptsAction.advanceReceiptInfos)}"/>
        </f:facet>
    </p:column>

    <p:column style="text-align:center" filterBy="#{advanceReceiptInfo.taxerManager}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="税管员"/>
        </f:facet>
        <h:outputText value="#{advanceReceiptInfo.taxerManager}"/>
        <f:facet name="footer">
            <h:commandLink>
                <h:outputText value="[导出数据]"/>
                <p:dataExporter type="xls" target="tabSum" fileName="yskhz"/>
            </h:commandLink>
        </f:facet>
    </p:column>
</p:dataTable>
<br/>
<p:separator/>
<p:dataTable id="tabDetail" style="width:100%;"
             value="#{advanceReceiptsAction.tickpxxbs}"
             var="tickpxxb"
             rowKey="#{tickpxxb.cFph}"
             selectionMode="single"
             selection="#{advanceReceiptsAction.tIckpxxbSelected}"
             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
             paginator="true"
             paginatorPosition="bottom"
             rows="15"
             rowsPerPageTemplate="100,50,30,15,5"
             emptyMessage="数据记录为空..."
             widgetVar="tabDetailVar">
    <f:facet name="header">
        <h:outputText value="预收款收据信息"/>
    </f:facet>

    <p:ajax event="rowSelect" listener="#{advanceReceiptsAction.updateTfpmxbInfo()}"
            update=":form:tfpmxb" oncomplete="showTfpmxb.show()"/>
    <p:column style="text-align:center" sortBy="#{tickpxxb.cFph}">
        <f:facet name="header">
            <h:outputText value="收据号码"/>
        </f:facet>
        <h:outputText value="#{tickpxxb.cFph}"/>
    </p:column>

    <p:column sortBy="#{tickpxxb.cFlag}" style="#{tickpxxb.cFlag == '冲红' ? 'text-align:center;color:red;' : 'text-align:center;'}">
        <f:facet name="header">
            <h:outputText value="状态"/>
        </f:facet>
        <h:outputText value="#{tickpxxb.cFlag}"/>
    </p:column>

    <p:column style="text-align:center" sortBy="#{tickpxxb.cFpje}">
        <f:facet name="header">
            <h:outputText value="发票金额"/>
        </f:facet>
        <h:outputText value="#{tickpxxb.cFpje}">
            <f:convertNumber pattern="##################.##"/>
        </h:outputText>
    </p:column>
    <p:column style="text-align:center" sortBy="#{tickpxxb.cDate}">
        <f:facet name="header">
            <h:outputText value="开票日期"/>
        </f:facet>
        <h:outputText value="#{tickpxxb.cDate}">
            <f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" locale="cn"></f:convertDateTime>
        </h:outputText>
    </p:column>

    <p:column style="text-align:center" sortBy="#{tickpxxb.cKhzzjgm}">
        <f:facet name="header">
            <h:outputText value="购房者证件号码"/>
        </f:facet>
        <h:outputText value="#{tickpxxb.cKhzzjgm}"/>
    </p:column>
    <p:column style="text-align:center" filterBy="#{tickpxxb.cKhname}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="购房者名称"/>
        </f:facet>
        <h:outputText value="#{tickpxxb.cKhname}"/>
    </p:column>

    <p:column style="text-align:center">
        <f:facet name="header">
            <h:outputText value="税控防伪码"/>
        </f:facet>
        <h:outputText value="#{tickpxxb.cSkfwm}"/>
    </p:column>

    <p:column style="text-align:center">
        <f:facet name="header">
            <h:outputText value="原发票号"/>
        </f:facet>
        <h:outputText value="#{tickpxxb.cYfph}"/>
        <f:facet name="footer">
            <h:outputText value="笔数：#{fn:length(advanceReceiptsAction.tickpxxbs)}"/>
        </f:facet>
    </p:column>

    <p:column style="text-align:center" filterBy="#{tickpxxb.cKpr}" filterMatchMode="contains">
        <f:facet name="header">
            <h:outputText value="开票人"/>
        </f:facet>
        <h:outputText value="#{tickpxxb.cKpr}"/>
        <f:facet name="footer">
            <h:commandLink>
                <h:outputText value="[导出数据]"/>
                <p:dataExporter type="xls" target="tabDetail" fileName="ysksjxx"/>
            </h:commandLink>
        </f:facet>
    </p:column>
</p:dataTable>
<p:dialog id="showTfpmxb" widgetVar="showTfpmxb" header="发票详情" modal="true" showEffect="drop"
          hideEffect="drop"
          height="140" width="500">
    <p:panelGrid id="tfpmxb" columns="4">
        <h:outputText value="收据号码"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.cFph}"/>
        <h:outputText value="开票项目"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.cSkxmhb}"/>
        <h:outputText value="项目名称"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.cSkxmmc}"/>
        <h:outputText value="会计项目"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.cKjxm}"/>
        <h:outputText value="数量"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.cNumber}"/>
        <h:outputText value="单位"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.cDj}"/>
        <h:outputText value="金额"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.cJe}">
            <f:convertNumber pattern="##################.##"/>
        </h:outputText>
        <h:outputText value="标识"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.fdcFlag}"/>
        <h:outputText value="计量单位"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.cDw}"/>
        <h:outputText value="开票日期"/>
        <h:outputText value="#{advanceReceiptsAction.tFpmxb.cDate.toLocaleString()}">
            <f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" locale="cn"></f:convertDateTime>
        </h:outputText>
    </p:panelGrid>
</p:dialog>
</h:form>
</div>
</ui:define>
</ui:composition>